package com.TeamJigsaw.DanteTrail.Views;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.border.TitledBorder;

import net.miginfocom.swing.MigLayout;

import com.TeamJigsaw.DanteTrail.Views.Interfaces.WagonViewInterface;
import java.awt.Color;

public class WagonView extends JPanel implements WagonViewInterface{
	
	private JLabel currentFood;
	private JLabel currentClothes;
	private JLabel currentAmmo;
	private String htmlStart;
	private String htmlEnd;
	private JLabel currentOxen;
	private JLabel currentWheels;
	private JLabel currentTongues;
	private JLabel currentAxels;
	private JLabel lblNewLabel_8;
	private JLabel lblNewLabel_9;
	private JPanel panel;
	private JLabel lblHellHoundsPulling;
	private JLabel lblWheelsWorking;
	private JLabel lblTongueFunctioning;
	private JLabel lblAxelsWorking;
	private JLabel lblNewLabel;
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel_2;
	private JLabel lblNewLabel_3;
	private JButton btnBackToTrail;

	public WagonView()
	{
		setSize(new Dimension(700,700));
		htmlStart = "<html><font size=\"4\" color=\"#FFFFFF\"><b>";
		htmlEnd = "</b></font></html>";
		initialize();
	}
	
	public void initialize()
	{
		setLayout(new MigLayout("", "[35:35.00:35][250:250:250][75:75:75][75:75:75][][50:50:50]", "[20:20:20][450:450:450][][40:40:40]"));
		
		panel = new JPanel();
		panel.setOpaque(false);
		panel.setBorder(new TitledBorder(null, "Wagon", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, Color.WHITE));
		add(panel, "cell 1 1 2 1,grow");
		panel.setLayout(new MigLayout("", "[][150:150:150][][][20:20:20]", "[][25:25:25][25:25:25][25:25:25][25:25:25][25:25:25][25:25:25][25:25:25]"));
		
		lblHellHoundsPulling = new JLabel(htmlStart+"Hell Hounds Pulling:"+htmlEnd);
		panel.add(lblHellHoundsPulling, "cell 1 1");
		
		lblNewLabel = new JLabel("New label");
		panel.add(lblNewLabel, "cell 3 1");
		
		lblWheelsWorking = new JLabel(htmlStart+"Wheels Working:"+htmlEnd);
		panel.add(lblWheelsWorking, "cell 1 3");
		
		lblNewLabel_1 = new JLabel("New label");
		panel.add(lblNewLabel_1, "cell 3 3");
		
		lblTongueFunctioning = new JLabel(htmlStart+"Tongue Functioning:"+htmlEnd);
		panel.add(lblTongueFunctioning, "cell 1 5");
		
		lblNewLabel_2 = new JLabel("New label");
		panel.add(lblNewLabel_2, "cell 3 5");
		
		lblAxelsWorking = new JLabel(htmlStart+"Axels Working:"+htmlEnd);
		panel.add(lblAxelsWorking, "cell 1 7");
		
		lblNewLabel_3 = new JLabel("New label");
		panel.add(lblNewLabel_3, "cell 3 7");
		JPanel panel_1 = new JPanel();
		panel_1.setOpaque(false);
		panel_1.setBorder(new TitledBorder(null, "Current Inventory", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, Color.WHITE));
		add(panel_1, "cell 4 1,grow");
		panel_1.setLayout(new MigLayout("", "[][][][20:20:20]", "[][25:25:25][][25:25:25][][25:25:25][][25:25:25][][25:25:25][][25:25:25][][25:25:25][]"));
		
		JLabel lblFood = new JLabel(htmlStart+"Food:"+htmlEnd);
		panel_1.add(lblFood, "cell 0 0");
		
		currentFood = new JLabel("New label");
		panel_1.add(currentFood, "cell 2 0");
		
		JLabel lblClothes = new JLabel(htmlStart+"Clothes"+htmlEnd);
		panel_1.add(lblClothes, "cell 0 2");
		
		currentClothes = new JLabel("New label");
		panel_1.add(currentClothes, "cell 2 2");
		
		JLabel lblAmmo = new JLabel(htmlStart+"Ammo:"+htmlEnd);
		panel_1.add(lblAmmo, "cell 0 4");
		
		currentAmmo = new JLabel("New label");
		panel_1.add(currentAmmo, "cell 2 4");
		
		JLabel lblOxen = new JLabel(htmlStart+"Hell Hound:"+htmlEnd);
		panel_1.add(lblOxen, "cell 0 6");
		
		currentOxen = new JLabel("New label");
		panel_1.add(currentOxen, "cell 2 6");
		
		JLabel lblWheels = new JLabel(htmlStart+"Wheels:"+htmlEnd);
		panel_1.add(lblWheels, "cell 0 8");
		
		currentWheels = new JLabel("New label");
		panel_1.add(currentWheels, "cell 2 8");
		
		JLabel lblTongue = new JLabel(htmlStart+"Tongues:"+htmlEnd);
		panel_1.add(lblTongue, "cell 0 10");
		
		currentTongues = new JLabel("New label");
		panel_1.add(currentTongues, "cell 2 10");
		
		JLabel lblAxels = new JLabel(htmlStart+"Axels:"+htmlEnd);
		panel_1.add(lblAxels, "cell 0 12");
		
		currentAxels = new JLabel("New label");
		panel_1.add(currentAxels, "cell 2 12");
		
		lblNewLabel_8 = new JLabel(htmlStart+"Total Weight:"+htmlEnd);
		panel_1.add(lblNewLabel_8, "cell 0 14,growx");
		
		lblNewLabel_9 = new JLabel("New label");
		panel_1.add(lblNewLabel_9, "cell 2 14");
		
		btnBackToTrail = new JButton("Back To Trail");
		add(btnBackToTrail, "cell 4 3,grow");
	}

	@Override
	public void setAmmo(int current) {
		currentAmmo.setText(htmlStart+current +htmlEnd);
		
	}

	@Override
	public void setFood(int current) {
		currentFood.setText(htmlStart+current + htmlEnd);
		
	}

	@Override
	public void setClothes(int current) {
		currentClothes.setText(htmlStart+current + htmlEnd);
		
	}

	@Override
	public void setOxen(int current) {
		currentOxen.setText(htmlStart+current + htmlEnd);
		
	}

	@Override
	public void setWheels(int current) {
		currentWheels.setText(htmlStart+current + htmlEnd);
		
	}

	@Override
	public void setTongues(int current) {
		currentTongues.setText(htmlStart+current +htmlEnd);
		
	}

	@Override
	public void setAxels(int current) {
		currentAxels.setText(htmlStart+current +htmlEnd);
		
	}

	@Override
	public void setInventoryWeight(int current, int max) {
		lblNewLabel_9.setText(htmlStart+ current + " / " + max + htmlEnd);
		
	}

	@Override
	public void setTrailListener(ActionListener listen) {
		btnBackToTrail.addActionListener(listen);
		
	}

	@Override
	public void setRepairListener(ActionListener listen) {
		//btnRepair.addActionListener(listen);
		
	}

	@Override
	public void setOxenWorking(int current) {
		lblNewLabel.setText(htmlStart+current + " / 2"+htmlEnd);
		
	}

	@Override
	public void setWheelsWorking(int current) {
		lblNewLabel_1.setText(htmlStart+current + " / 4"+htmlEnd);
		
	}

	@Override
	public void setAxelsWorking(int current) {
		lblNewLabel_3.setText(htmlStart+current + " / 2"+htmlEnd);
		
	}

	@Override
	public void setTongueWorking(boolean working) {
		if(working)
			lblNewLabel_2.setText(htmlStart+"Yes"+htmlEnd);
		else
			lblNewLabel_2.setText(htmlStart+"No"+htmlEnd);
		
	}
	
	@Override
	public boolean listenersExist() {
		if(btnBackToTrail.getActionListeners().length > 0)
			return true;
		
		return false;
	}
	
	@Override
	public void paintComponent(Graphics g) {
		ImageIcon img = new ImageIcon("resources\\stone_texture.png");
	    g.drawImage(img.getImage(), 0, 0, null);
	  }

}
